package com.leorui.schoollife.entity

import net.sf.json.JSONArray
import net.sf.json.JSONObject
import java.io.Serializable

class PhotoEntityResponse : Serializable {
    var status: Int? = null
    var msg: String? = null
    var photoList: List<PhotoEntity?>? = null

    constructor(status: Int?, msg: String?) : this(status, msg, null)

    constructor(status: Int?, msg: String?, photoList: List<PhotoEntity?>?) {
        this.status = status
        this.msg = msg
        this.photoList = photoList
    }

    fun toMap(): Map<Any?, Any?> {
        val json = JSONObject()
        json["status"] = status
        json["msg"] = msg
        val list = JSONArray()
        photoList?.forEach {
            list.add(it?.toMap())
        }
        json["photo_list"] = list.toList()
        return json.toMap()
    }
}

class PhotoEntity : Serializable {
    var iconId: String? = null
    var iconSrc: String? = null

    constructor() : this(null, null)

    constructor(iconId: String? = null, iconSrc: String? = null) {
        this.iconId = iconId
        this.iconSrc = iconSrc
    }

    fun toJson():JSONObject{
        val json = JSONObject()
        json["icon_id"] = iconId
        json["icon_src"] = iconSrc
        return json
    }

    fun toMap(): Map<Any?, Any?> {
        val json = JSONObject()
        json["icon_id"] = iconId
        json["icon_src"] = iconSrc
        return json.toMap()
    }
}